import java.util.HashMap;
import java.util.Map;

public class TestMapCollision {
	public static void main(String[] args) {
		Map map = new HashMap();
		Personel p0 = new Personel(0, "Egemen");
		Personel p1 = new Personel(1, "Osman");
		Personel p2 = new Personel(2, "Deniz");
		Personel p3 = new Personel(1, "Sercan");
		Personel p4 = new Personel(3, "Ayse");
		Personel p5 = new Personel(3, "Cansu");
		Personel p6 = new Personel(2, "Onur");
		System.out.println("Add Entries ....");
		map.put(p0, "0");
		map.put(p1, "1");
		map.put(p2, "2");
		map.put(p3, "3");
		map.put(p4, "4");
		map.put(p5, "5");
		map.put(p6, "6");
		System.out.println("\nTum Map entry\n" + map);
		System.out.println("\nnon-collided key");
		System.out.println("Value = " + map.get(p0));
		System.out.println("\ncollided key");
		System.out.println("Value = " + map.get(p1));
		System.out.println("Value = " + map.get(p2));
		System.out.println("Value = " + map.get(p4));
	}
}

class Personel {
	private int id;
	private String name;

	public Personel(int id, String name) {
		this.id = id;
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	// public String toString() {
	// return id + " - " + name;
	// }

	@Override
	public int hashCode() {
		System.out.println("hashCode metod =" + id + "." + name);
		// final int prime = 31;
		// int result = 1;
		// result = prime * result + id;
		// result = prime * result + ((name == null) ? 0 : name.hashCode());
		// return result;
		return id;
	}

	@Override
	public boolean equals(Object obj) {
		System.out.println("equals metod =" + id + "." + name + "  compare = "
				+ ((Personel) obj).getId() + "." + ((Personel) obj).getName());
		boolean result = true;

		if (this == obj)
			result = true;
		if (obj == null)
			result = false;
		if (getClass() != obj.getClass())
			result = false;
		Personel other = (Personel) obj;
		if (id != other.id)
			result = false;
		if (name == null) {
			if (other.name != null)
				result = false;
		} else if (!name.equals(other.name))
			result = false;

		System.out.println("result : " + result);
		return result;
	}
}